$OpenBSD: patch-file_c,v 1.3 2010/05/26 13:53:16 jasper Exp $
--- file.c.orig	Sat Sep 17 20:38:53 2005
+++ file.c	Wed Mar 24 12:18:35 2010
@@ -18,6 +18,7 @@
  */
 
 
+#include <string.h>
 #include "mpage.h"
 
 
@@ -119,11 +120,11 @@ do_pr_file(fname, asheet, outfd)
      */
 #define DASHES "-- "
     if (opt_header != NULL)
-        (void)sprintf(command, "%s -l%d -w%d -h \"%s\" %s%s", prprog,
+        (void)snprintf(command, sizeof(command),"%s -l%d -w%d -h \"%s\" %s%s", prprog,
                   asheet->sh_plength, asheet->sh_cwidth, opt_header,
                   fname[0] == '-' ? DASHES : "", fname);
     else
-        (void)sprintf(command, "%s -l%d -w%d %s%s", prprog,
+        (void)snprintf(command, sizeof(command), "%s -l%d -w%d %s%s", prprog,
                   asheet->sh_plength, asheet->sh_cwidth,
                   fname[0] == '-' ? DASHES : "", fname);
     /*
@@ -168,7 +169,7 @@ do_stdin(asheet, outfd)
      * but the tmpfilename
      */
      
-    (void) strcpy(tmpfile, "/tmp/mpage-stdin-XXXXXX");
+    (void) strlcpy(tmpfile, "/tmp/mpage-stdin-XXXXXX", sizeof(tmpfile));
     if ( (tmpfd = mkstemp(tmpfile)) == -1) {
         fprintf(stderr, "%s: cannot create temporary file", MPAGE);
         perror(MPAGE);
@@ -209,7 +210,7 @@ do_stdin(asheet, outfd)
          * a temporary file; this temporary file will then
          * be used as input to the do_doc routine
          */
-        (void)strcpy(tmpfile, "/tmp/mpageXXXXXX");
+        (void)strlcpy(tmpfile, "/tmp/mpageXXXXXX", sizeof(tmpfile));
         if ( (tmpfd = mkstemp(tmpfile)) == -1) {
             fprintf(stderr, "%s: cannot create temporary file", MPAGE);
             perror(MPAGE);
@@ -217,11 +218,11 @@ do_stdin(asheet, outfd)
 	}
         close(tmpfd);
         if (opt_header != NULL)
-            (void)sprintf(command, "%s -l%d -w%d -h \"%s\" > %s", prprog,
+            (void)snprintf(command, sizeof(command), "%s -l%d -w%d -h \"%s\" > %s", prprog,
                       asheet->sh_plength, asheet->sh_cwidth,
                       opt_header, tmpfile);
         else
-            (void)sprintf(command, "%s -l%d -w%d > %s", prprog,
+            (void)snprintf(command, sizeof(command), "%s -l%d -w%d > %s", prprog,
                       asheet->sh_plength, asheet->sh_cwidth, tmpfile);
         /*
          * open a pipe to the pr(1) command which will create a
@@ -281,7 +282,7 @@ do_stdin(asheet, outfd)
 	/*
 	 * store the input to the temporary file to guess encoding correctly
 	 */
-        (void)strcpy(tmpfile, "/tmp/mpageXXXXXX");
+        (void)strlcpy(tmpfile, "/tmp/mpageXXXXXX", sizeof(tmpfile));
         if ( (tmpfd = mkstemp(tmpfile)) == -1) {
             fprintf(stderr, "%s: cannot create temporary file", MPAGE);
 	    tmpfile[0] = 0;
